@strapi/admin 4.1.4-alpha.2 → 4.2.0-alpha.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/.env +0 -0
  2. package/admin/src/app.js +7 -4
  3. package/admin/src/components/GuidedTour/Homepage/index.js +13 -3
  4. package/admin/src/components/GuidedTour/Modal/index.js +4 -1
  5. package/admin/src/components/GuidedTour/layout.js +9 -0
  6. package/admin/src/content-manager/components/Inputs/index.js +3 -4
  7. package/admin/src/hooks/index.js +1 -0
  8. package/admin/src/hooks/useFetchPluginsFromMarketPlace/index.js +49 -0
  9. package/admin/src/pages/AuthPage/index.js +1 -0
  10. package/admin/src/pages/InstalledPluginsPage/Plugins.js +15 -6
  11. package/admin/src/{hooks/useFetchInstalledPlugins → pages/InstalledPluginsPage}/utils/api.js +4 -2
  12. package/admin/src/pages/MarketplacePage/MarketplaceBanner/Wrapper.js +28 -0
  13. package/admin/src/pages/MarketplacePage/MarketplaceBanner/index.js +37 -0
  14. package/admin/src/pages/MarketplacePage/PluginCard/Wrapper.js +148 -0
  15. package/admin/src/pages/MarketplacePage/PluginCard/index.js +185 -0
  16. package/admin/src/pages/MarketplacePage/Wrapper.js +5 -0
  17. package/admin/src/pages/MarketplacePage/assets/marketplace-coming-soon.png +0 -0
  18. package/admin/src/pages/MarketplacePage/index.js +107 -199
  19. package/admin/src/translations/en.json +15 -18
  20. package/admin/src/translations/ja.json +2 -2
  21. package/admin/src/translations/ko.json +2 -2
  22. package/build/01a600d9e6e0dea21e33.png +0 -0
  23. package/build/4362.dbe98749.chunk.js +1 -0
  24. package/build/9260.d9bb874f.chunk.js +2 -0
  25. package/build/{9260.fa40c7bd.chunk.js.LICENSE.txt → 9260.d9bb874f.chunk.js.LICENSE.txt} +0 -0
  26. package/build/Admin-authenticatedApp.a24ebaa0.chunk.js +1 -0
  27. package/build/Admin_homePage.86604515.chunk.js +1 -0
  28. package/build/Admin_marketplace.419010d8.chunk.js +1 -0
  29. package/build/Admin_pluginsPage.7d1bd7ce.chunk.js +1 -0
  30. package/build/admin-users.1fda1f27.chunk.js +1 -0
  31. package/build/content-manager.31be1448.chunk.js +1 -0
  32. package/build/en-json.bce44d39.chunk.js +1 -0
  33. package/build/index.html +1 -1
  34. package/build/ja-json.e13f04e8.chunk.js +1 -0
  35. package/build/ko-json.2200c9c9.chunk.js +1 -0
  36. package/build/{main.7fa5bc38.js → main.4ea77c5f.js} +2 -2
  37. package/build/{main.7fa5bc38.js.LICENSE.txt → main.4ea77c5f.js.LICENSE.txt} +0 -0
  38. package/build/{runtime~main.7bb09ab1.js → runtime~main.83b9ee0b.js} +1 -1
  39. package/index.js +53 -244
  40. package/package.json +7 -5
  41. package/server/controllers/admin.js +1 -12
  42. package/server/routes/serve-admin-panel.js +1 -1
  43. package/utils/create-cache-dir.js +119 -0
  44. package/utils/get-custom-webpack-config.js +38 -0
  45. package/utils/index.js +13 -0
  46. package/utils/should-build-admin.js +51 -0
  47. package/utils/watch-admin-files.js +56 -0
  48. package/webpack.config.js +36 -3
  49. package/admin/src/assets/images/icon_made-by-strapi.svg +0 -5
  50. package/admin/src/hooks/useFetchInstalledPlugins/index.js +0 -23
  51. package/admin/src/hooks/useFetchMarketplacePlugins/index.js +0 -23
  52. package/admin/src/hooks/useFetchMarketplacePlugins/utils/api.js +0 -17
  53. package/admin/src/pages/MarketplacePage/components/EmptyPluginSearch/EmptyPluginGrid.js +0 -27
  54. package/admin/src/pages/MarketplacePage/components/EmptyPluginSearch/index.js +0 -30
  55. package/admin/src/pages/MarketplacePage/components/PluginCard/index.js +0 -186
  56. package/admin/src/pages/MarketplacePage/utils/api.js +0 -9
  57. package/build/4362.5c92d240.chunk.js +0 -1
  58. package/build/90f49a385afb000fb1d4.svg +0 -5
  59. package/build/9260.fa40c7bd.chunk.js +0 -2
  60. package/build/Admin-authenticatedApp.6d27d55a.chunk.js +0 -1
  61. package/build/Admin_homePage.964ff5d7.chunk.js +0 -1
  62. package/build/Admin_marketplace.89a0a014.chunk.js +0 -1
  63. package/build/Admin_pluginsPage.97a514db.chunk.js +0 -1
  64. package/build/admin-users.2740c223.chunk.js +0 -1
  65. package/build/content-manager.e1189026.chunk.js +0 -1
  66. package/build/en-json.086acf41.chunk.js +0 -1
  67. package/build/ja-json.46e29f04.chunk.js +0 -1
  68. package/build/ko-json.dd36fdc0.chunk.js +0 -1
package/.env ADDED
File without changes
package/admin/src/app.js CHANGED
@@ -1,6 +1,9 @@
1
+ const config = {
2
+ locales: ['fr'],
3
+ };
4
+ const bootstrap = () => {};
5
+
1
6
  export default {
2
- config: {
3
- locales: ['fr'],
4
- },
5
- bootstrap() {},
7
+ config,
8
+ bootstrap,
6
9
  };
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { useGuidedTour } from '@strapi/helper-plugin';
2
+ import { useGuidedTour, useTracking } from '@strapi/helper-plugin';
3
3
  import { useIntl } from 'react-intl';
4
4
  import { Stack } from '@strapi/design-system/Stack';
5
5
  import { Flex } from '@strapi/design-system/Flex';
@@ -14,12 +14,17 @@ import layout from '../layout';
14
14
  const GuidedTourHomepage = () => {
15
15
  const { guidedTourState, setSkipped } = useGuidedTour();
16
16
  const { formatMessage } = useIntl();
17
+ const { trackUsage } = useTracking();
17
18
 
18
19
  const sections = Object.entries(layout).map(([key, val]) => ({
19
20
  key,
20
21
  title: val.home.title,
21
22
  content: (
22
- <LinkButton to={val.home.cta.target} endIcon={<ArrowRight />}>
23
+ <LinkButton
24
+ onClick={() => trackUsage(val.home.trackingEvent)}
25
+ to={val.home.cta.target}
26
+ endIcon={<ArrowRight />}
27
+ >
23
28
  {formatMessage(val.home.cta.title)}
24
29
  </LinkButton>
25
30
  ),
@@ -32,6 +37,11 @@ const GuidedTourHomepage = () => {
32
37
 
33
38
  const activeSection = enrichedSections.find(section => !section.isDone)?.key;
34
39
 
40
+ const handleSkip = () => {
41
+ setSkipped(true);
42
+ trackUsage('didSkipGuidedtour');
43
+ };
44
+
35
45
  return (
36
46
  <Box
37
47
  hasRadius
@@ -52,7 +62,7 @@ const GuidedTourHomepage = () => {
52
62
  <StepperHomepage sections={sections} currentSectionKey={activeSection} />
53
63
  </Stack>
54
64
  <Flex justifyContent="flex-end">
55
- <Button variant="tertiary" onClick={() => setSkipped(true)}>
65
+ <Button variant="tertiary" onClick={handleSkip}>
56
66
  {formatMessage({ id: 'app.components.GuidedTour.skip', defaultMessage: 'Skip the tour' })}
57
67
  </Button>
58
68
  </Flex>
@@ -1,6 +1,6 @@
1
1
  import React, { useEffect, useState, useReducer } from 'react';
2
2
  import at from 'lodash/at';
3
- import { useGuidedTour } from '@strapi/helper-plugin';
3
+ import { useGuidedTour, useTracking } from '@strapi/helper-plugin';
4
4
  import layout from '../layout';
5
5
  import Modal from './components/Modal';
6
6
  import reducer, { initialState } from './reducer';
@@ -20,6 +20,7 @@ const GuidedTourModal = () => {
20
20
  { stepContent, sectionIndex, stepIndex, hasSectionAfter, hasStepAfter },
21
21
  dispatch,
22
22
  ] = useReducer(reducer, initialState);
23
+ const { trackUsage } = useTracking();
23
24
 
24
25
  useEffect(() => {
25
26
  if (!currentStep) {
@@ -56,6 +57,7 @@ const GuidedTourModal = () => {
56
57
 
57
58
  const handleCtaClick = () => {
58
59
  setStepState(currentStep, true);
60
+ trackUsage(stepContent.trackingEvent);
59
61
 
60
62
  setCurrentStep(null);
61
63
  };
@@ -63,6 +65,7 @@ const GuidedTourModal = () => {
63
65
  const handleSkip = () => {
64
66
  setSkipped(true);
65
67
  setCurrentStep(null);
68
+ trackUsage('didSkipGuidedtour');
66
69
  };
67
70
 
68
71
  if (isVisible && stepContent) {
@@ -13,6 +13,7 @@ const layout = {
13
13
  type: 'REDIRECT',
14
14
  target: '/plugins/content-type-builder',
15
15
  },
16
+ trackingEvent: 'didClickGuidedTourHomepageContentTypeBuilder',
16
17
  },
17
18
  create: {
18
19
  title: {
@@ -31,6 +32,7 @@ const layout = {
31
32
  },
32
33
  type: 'CLOSE',
33
34
  },
35
+ trackingEvent: 'didClickGuidedTourStep1CollectionType',
34
36
  },
35
37
  success: {
36
38
  title: {
@@ -49,6 +51,7 @@ const layout = {
49
51
  type: 'REDIRECT',
50
52
  target: '/content-manager',
51
53
  },
54
+ trackingEvent: 'didCreateGuidedTourCollectionType',
52
55
  },
53
56
  },
54
57
  contentManager: {
@@ -65,6 +68,7 @@ const layout = {
65
68
  type: 'REDIRECT',
66
69
  target: '/content-manager',
67
70
  },
71
+ trackingEvent: 'didClickGuidedTourHomepageContentManager',
68
72
  },
69
73
  create: {
70
74
  title: {
@@ -83,6 +87,7 @@ const layout = {
83
87
  },
84
88
  type: 'CLOSE',
85
89
  },
90
+ trackingEvent: 'didClickGuidedTourStep2ContentManager',
86
91
  },
87
92
  success: {
88
93
  title: {
@@ -101,6 +106,7 @@ const layout = {
101
106
  type: 'REDIRECT',
102
107
  target: '/settings/api-tokens',
103
108
  },
109
+ trackingEvent: 'didCreateGuidedTourEntry',
104
110
  },
105
111
  },
106
112
  apiTokens: {
@@ -117,6 +123,7 @@ const layout = {
117
123
  type: 'REDIRECT',
118
124
  target: '/settings/api-tokens',
119
125
  },
126
+ trackingEvent: 'didClickGuidedTourHomepageApiTokens',
120
127
  },
121
128
  create: {
122
129
  title: {
@@ -135,6 +142,7 @@ const layout = {
135
142
  },
136
143
  type: 'CLOSE',
137
144
  },
145
+ trackingEvent: 'didClickGuidedTourStep3ApiTokens',
138
146
  },
139
147
  success: {
140
148
  title: {
@@ -146,6 +154,7 @@ const layout = {
146
154
  defaultMessage:
147
155
  "<p>See content in action by making an HTTP request:</p><ul><li><p>To this URL: <light>https://'<'YOUR_DOMAIN'>'/api/'<'YOUR_CT'>'</light></p></li><li><p>With the header: <light>Authorization: bearer '<'YOUR_API_TOKEN'>'</light></p></li></ul><p>For more ways to interact with content, see the <documentationLink>documentation</documentationLink>.</p>",
148
156
  },
157
+ trackingEvent: 'didGenerateGuidedTourApiTokens',
149
158
  },
150
159
  },
151
160
  };
@@ -224,6 +224,8 @@ function Inputs({
224
224
  attribute={fieldSchema}
225
225
  autoComplete="new-password"
226
226
  intlLabel={{ id: label, defaultMessage: label }}
227
+ // in case the default value of the boolean is null, attribute.default doesn't exist
228
+ isNullable={inputType === 'bool' && [null, undefined].includes(fieldSchema.default)}
227
229
  description={description ? { id: description, defaultMessage: description } : null}
228
230
  disabled={shouldDisableField}
229
231
  error={errorId}
@@ -279,7 +281,4 @@ Inputs.propTypes = {
279
281
 
280
282
  const Memoized = memo(Inputs, isEqual);
281
283
 
282
- export default connect(
283
- Memoized,
284
- select
285
- );
284
+ export default connect(Memoized, select);
@@ -1,6 +1,7 @@
1
1
  export { default as useConfigurations } from './useConfigurations';
2
2
  export { default as useModels } from './useModels';
3
3
  export { default as useFetchPermissionsLayout } from './useFetchPermissionsLayout';
4
+ export { default as useFetchPluginsFromMarketPlace } from './useFetchPluginsFromMarketPlace';
4
5
  export { default as useFetchRole } from './useFetchRole';
5
6
  export { default as useMenu } from './useMenu';
6
7
  export { default as useRolesList } from './useRolesList';
@@ -0,0 +1,49 @@
1
+ import { useEffect, useState } from 'react';
2
+ import axios from 'axios';
3
+ import { useIntl } from 'react-intl';
4
+
5
+ const useFetchPluginsFromMarketPlace = () => {
6
+ const { locale: currentLocale } = useIntl();
7
+ const [state, setState] = useState({
8
+ error: false,
9
+ isLoading: true,
10
+ data: null,
11
+ });
12
+
13
+ useEffect(() => {
14
+ const CancelToken = axios.CancelToken;
15
+ const source = CancelToken.source();
16
+
17
+ const getData = async () => {
18
+ try {
19
+ const { data } = await axios.get('https://marketplace.strapi.io/plugins', {
20
+ cancelToken: source.token,
21
+ params: { lang: currentLocale },
22
+ });
23
+
24
+ setState({
25
+ isLoading: false,
26
+ data,
27
+ error: false,
28
+ });
29
+ } catch (err) {
30
+ if (axios.isCancel(err)) {
31
+ // Silent
32
+ } else {
33
+ // handle error
34
+ setState(prev => ({ ...prev, isLoading: false, error: true }));
35
+ }
36
+ }
37
+ };
38
+
39
+ getData();
40
+
41
+ return () => {
42
+ source.cancel();
43
+ };
44
+ }, [currentLocale]);
45
+
46
+ return state;
47
+ };
48
+
49
+ export default useFetchPluginsFromMarketPlace;
@@ -174,6 +174,7 @@ const AuthPage = ({ hasAdmin, setHasAdmin }) => {
174
174
  if (isUserSuperAdmin) {
175
175
  persistStateToLocaleStorage.setSkipped(false);
176
176
  setSkipped(false);
177
+ trackUsage('didLaunchGuidedtour');
177
178
  }
178
179
  }
179
180
 
@@ -1,24 +1,26 @@
1
1
  import React from 'react';
2
+ import { useQuery } from 'react-query';
2
3
  import { useIntl } from 'react-intl';
3
- import { LoadingIndicatorPage, useFocusWhenNavigate } from '@strapi/helper-plugin';
4
- import { useNotifyAT } from '@strapi/design-system/LiveRegions';
4
+ import { LoadingIndicatorPage, useNotification, useFocusWhenNavigate } from '@strapi/helper-plugin';
5
5
  import { Layout, HeaderLayout, ContentLayout } from '@strapi/design-system/Layout';
6
6
  import { Main } from '@strapi/design-system/Main';
7
+ import { useNotifyAT } from '@strapi/design-system/LiveRegions';
7
8
  import { Typography } from '@strapi/design-system/Typography';
8
9
  import { Table, Thead, Tbody, Tr, Td, Th } from '@strapi/design-system/Table';
9
- import useFetchInstalledPlugins from '../../hooks/useFetchInstalledPlugins';
10
+ import { fetchPlugins } from './utils/api';
10
11
 
11
12
  const Plugins = () => {
12
13
  const { formatMessage } = useIntl();
13
- const { notifyStatus } = useNotifyAT();
14
14
  useFocusWhenNavigate();
15
+ const { notifyStatus } = useNotifyAT();
16
+ const toggleNotification = useNotification();
15
17
 
16
18
  const title = formatMessage({
17
19
  id: 'app.components.ListPluginsPage.title',
18
20
  defaultMessage: 'Plugins',
19
21
  });
20
22
 
21
- const notifyPluginPageLoad = () => {
23
+ const notifyLoad = () => {
22
24
  notifyStatus(
23
25
  formatMessage(
24
26
  {
@@ -30,7 +32,14 @@ const Plugins = () => {
30
32
  );
31
33
  };
32
34
 
33
- const { status, data } = useFetchInstalledPlugins(notifyPluginPageLoad);
35
+ const { status, data } = useQuery('list-plugins', () => fetchPlugins(notifyLoad), {
36
+ onError: () => {
37
+ toggleNotification({
38
+ type: 'warning',
39
+ message: { id: 'notification.error', defaultMessage: 'An error occured' },
40
+ });
41
+ },
42
+ });
34
43
 
35
44
  const isLoading = status !== 'success' && status !== 'error';
36
45
 
@@ -1,9 +1,11 @@
1
1
  import { axiosInstance } from '../../../core/utils';
2
2
 
3
- const fetchInstalledPlugins = async () => {
3
+ const fetchPlugins = async notify => {
4
4
  const { data } = await axiosInstance.get('/admin/plugins');
5
5
 
6
+ notify();
7
+
6
8
  return data;
7
9
  };
8
10
 
9
- export { fetchInstalledPlugins };
11
+ export { fetchPlugins };
@@ -0,0 +1,28 @@
1
+ import styled from 'styled-components';
2
+
3
+ // TODO : To migrate with @strapi/design-system
4
+ const Wrapper = styled.div`
5
+ display: flex;
6
+ align-items: center;
7
+ margin-top: 2rem;
8
+ border-radius: 4px;
9
+ border-left: 4px solid ${({ theme }) => theme.main.colors.mediumBlue};
10
+ box-shadow: 0 2px 4px ${({ theme }) => theme.main.colors.darkGrey};
11
+ padding: 8px 16px;
12
+
13
+ .bannerImage {
14
+ width: 48px;
15
+ height: 48px;
16
+ margin-right: 16px;
17
+ }
18
+
19
+ .bannerLink {
20
+ color: ${({ theme }) => theme.main.colors.mediumBlue};
21
+ font-weight: ${({ theme }) => theme.main.fontWeights.bold};
22
+ svg {
23
+ margin-left: 4px;
24
+ }
25
+ }
26
+ `;
27
+
28
+ export default Wrapper;
@@ -0,0 +1,37 @@
1
+ import React from 'react';
2
+ import { FormattedMessage, useIntl } from 'react-intl';
3
+ import { useTracking } from '@strapi/helper-plugin';
4
+ import Wrapper from './Wrapper';
5
+ import LogoStrapi from '../../../assets/images/banner_strapi-rocket.png';
6
+
7
+ const MarketplaceBanner = () => {
8
+ const { formatMessage } = useIntl();
9
+ const { trackUsage } = useTracking();
10
+
11
+ return (
12
+ <Wrapper>
13
+ <img
14
+ className="bannerImage"
15
+ src={LogoStrapi}
16
+ alt={formatMessage({ id: 'app.components.MarketplaceBanner.image.alt' })}
17
+ />
18
+ <div>
19
+ <div>
20
+ <FormattedMessage id="app.components.MarketplaceBanner" />
21
+ </div>
22
+ <a
23
+ href="https://github.com/strapi/awesome-strapi"
24
+ target="_blank"
25
+ rel="noopener noreferrer"
26
+ className="bannerLink"
27
+ onClick={() => trackUsage('didGoToStrapiAwesome')}
28
+ >
29
+ <FormattedMessage id="app.components.MarketplaceBanner.link" />
30
+ <i className="fa fa-external-link-alt" />
31
+ </a>
32
+ </div>
33
+ </Wrapper>
34
+ );
35
+ };
36
+
37
+ export default MarketplaceBanner;
@@ -0,0 +1,148 @@
1
+ import styled from 'styled-components';
2
+
3
+ const Wrapper = styled.div`
4
+ .wrapper {
5
+ position: relative;
6
+ min-height: 216px;
7
+ margin-bottom: 3.6rem;
8
+ padding: 1.2rem 1.5rem;
9
+ padding-bottom: 0;
10
+ background-color: #fff;
11
+ box-shadow: 0 2px 4px #e3e9f3;
12
+ -webkit-font-smoothing: antialiased;
13
+ }
14
+
15
+ .cardTitle {
16
+ display: flex;
17
+ font-size: 13px;
18
+ font-weight: 600;
19
+ text-transform: uppercase;
20
+ letter-spacing: 0.5px;
21
+
22
+ > div:first-child {
23
+ margin-right: 14px;
24
+ }
25
+
26
+ > div:last-child {
27
+ height: 36px;
28
+ line-height: 36px;
29
+ }
30
+
31
+ i,
32
+ svg {
33
+ margin-left: 7px;
34
+ color: #b3b5b9;
35
+ font-size: 1rem;
36
+ vertical-align: baseline;
37
+ cursor: pointer;
38
+ }
39
+ }
40
+
41
+ .cardDescription {
42
+ height: 54px;
43
+ margin-top: 27px;
44
+ margin-bottom: 9px;
45
+ font-size: 13px;
46
+ font-weight: 400;
47
+
48
+ > span:last-child {
49
+ color: #1c5de7;
50
+ }
51
+ -webkit-font-smoothing: antialiased;
52
+ }
53
+
54
+ .cardFooter {
55
+ position: absolute;
56
+ bottom: 0;
57
+ left: 0;
58
+ display: flex;
59
+ width: 100%;
60
+ height: 45px;
61
+ padding: 0.9rem 1.5rem 1rem;
62
+ background-color: #fafafb;
63
+ justify-content: space-between;
64
+ flex-direction: row-reverse;
65
+ cursor: initial;
66
+ }
67
+
68
+ .compatible {
69
+ margin-top: 3px;
70
+ color: #5a9e06;
71
+ font-size: 1.3rem;
72
+ font-style: italic;
73
+
74
+ > i,
75
+ > svg {
76
+ margin-right: 7px;
77
+ font-size: 12px;
78
+ }
79
+ }
80
+
81
+ .settings {
82
+ margin-top: 3px;
83
+ color: #323740;
84
+ font-size: 1.3rem;
85
+ font-weight: 500;
86
+ cursor: pointer;
87
+
88
+ > i,
89
+ > svg {
90
+ margin-right: 7px;
91
+ font-size: 11px;
92
+ vertical-align: inherit;
93
+ }
94
+ }
95
+
96
+ .button {
97
+ height: 26px;
98
+ min-width: 89px !important;
99
+ padding: 0 15px;
100
+ margin: 0;
101
+ border-radius: 2px !important;
102
+ line-height: 23px;
103
+ font-size: 13px;
104
+ cursor: pointer;
105
+ span {
106
+ display: inline-block;
107
+ width: 100%;
108
+ height: 100%;
109
+ }
110
+ }
111
+
112
+ .frame {
113
+ width: 70px;
114
+ height: 36px;
115
+ margin: auto 0;
116
+ text-align: center;
117
+ border: 1px solid #f3f3f7;
118
+ border-radius: 3px;
119
+ white-space: nowrap;
120
+ > img {
121
+ max-height: 36px;
122
+ vertical-align: middle;
123
+ }
124
+ }
125
+
126
+ .helper {
127
+ display: inline-block;
128
+ height: 100%;
129
+ vertical-align: middle;
130
+ }
131
+ .primary {
132
+ background: linear-gradient(315deg, #0097f6 0%, #005eea 100%);
133
+ color: white;
134
+ font-weight: 500;
135
+ -webkit-font-smoothing: antialiased;
136
+
137
+ &:active {
138
+ box-shadow: inset 1px 1px 3px rgba(0, 0, 0, 0.15);
139
+ }
140
+ }
141
+
142
+ .secondary {
143
+ border: 1px solid #dfe0e1;
144
+ font-weight: 600;
145
+ }
146
+ `;
147
+
148
+ export default Wrapper;